<?php

if(!defined('OT_ROOT')) {
	exit('Access Denied');
}



class UcBase{

	public static $infoNum = 0;

	// 读取验证码 会员中心登录注册使用
	public static function VerCode($spvcForm,$spvcId=''){
		if (OT_OpenVerCode){
			global $systemArr;

			if ($systemArr['SYS_verCodeMode'] == 20){
				$jsStr = '<script language="javascript" type="text/javascript">geetWidth = "100%";</script>';
				$jsPara = 'geetWidth=100%';
				return '<div id="geetestDiv"></div>
						<p id="geetestWait" style="color:blue;display:none;">正在加载验证码......</p>
						<p id="geetestNote" style="display:none;">请先完成验证</p>
						'. $jsStr .'
						<script id="geetestBox" language="javascript" type="text/javascript" src="../tools/geetest/gt.js?v=1.0" data="'. $jsPara .'"></script>
						';
			}else{
				if (empty($spvcId)){ $spvcId='verCode'; }
				return '<div class="form-item">
					<div class="input-warp gap">
	                    <span class="input-icon iconfont icon-yanzhengma"></span>
	                    <input id="'. $spvcId .'" name="verCode" placeholder="验证码" maxlength="16" type="text" autocomplete="off" onfocus=\'GetVerCode("input")\' title="如看不清验证码，可以点击验证码进行更换" class="form-control" style="width:120px;display:inline;" />
	                	<span id="showVerCode" onclick=\'GetVerCode("font")\' style="margin:8px 0 0 8px;cursor:pointer;color:red;">点击获取验证码</span>
	                </div>
	            </div>';
			}
		}else{
			return '';
		}
	}

	// 判断是否访客移动端访问
	public static function JudMobile(){
		global $systemArr;
		if (AppWap::Jud() && Is::Mobile() && $systemArr['SYS_isWap'] == 1){
			return true;
		}else{
			return false;
		}
	}

	// 判断是否来至手机版独立域名
	public static function JudWapDomain(){
		$currURL = GetUrl::Curr();
		if (strpos($currURL,'/wap/users/') === false){
			return true;
		}else{
			return false;
		}
	}

	// 获取前台网址
	public static function BeforeURL(){
		global $systemArr;
		if (self::JudWapDomain()){
			$retStr = $systemArr['SYS_URL'];
		}else{
			$retStr = GetUrl::CurrDir(2);
		}
		return $retStr;
	}

	// 判断是否访客移动端访问（删除 废弃）
	public static function JudWap(){
		return self::JudMobile();
	}

	// 判断是否来至电脑版模板（删除 废弃）
	public static function JudPcTpl(){
		$currURL = GetUrl::Curr();
		if (strpos($currURL,'/wap/users/') !== false){
			return true;
		}else{
			return false;
		}
	}

	// 根据访问端显示对应内容
	public static function PcWapShow($pcStr, $wapStr){
		if (self::JudMobile()){
			return $wapStr;
		}else{
			return $pcStr;
		}
	}

	// 根据访问端显示上2级还是上1级
	public static function PcWapParDir(){
		return self::PcWapShow('../../', '../');
	}

	// 根据访问端显示上2级还是上1级
	public static function PcWapOldDir($mode='uc'){
		if ($mode == 'uc'){
			return self::PcWapParDir();
		}else{
			return '';
		}
	}

	// 列表页 每页数量
	public static function PageNum($userRow){
		if (self::JudMobile()){
			return $userRow['UE_pageWapNum'];
		}else{
			return $userRow['UE_pageNum'];
		}
	}

	// 列表导航条
	public static function Nav($page, $pageCount, $pageSize, $recordCount){
		if (self::JudMobile()){
			return '<center>'. WapList::Nav('page','',0,$page,$pageCount,$pageSize,$recordCount) .'</center>';
		}else{
			return '
				<table cellpadding="0" cellspacing="0" align="center" class="listNavBox"><tr><td>
				'. Nav::Show('',$pageCount,$pageSize,$recordCount,'img','pageNum','uc') .'
				</td></tr></table>
				';
		}
	}


	// 栏目模式路径
	public static function InfoTypeUrl($itArr=array()){
		if ($itArr['IT_mode'] == 'url'){
			$retStr = $itArr['IT_URL'];
		}else{
			$retStr = '?m=infoType&id='. $itArr['IT_ID'] . (empty($itArr['id2']) ? '' : '&id2='. $itArr['id2']);
		}
		return $retStr;
	}


	// 表单 内容
	public static function FormText($theme, $value, $divAddi=''){
		return '
			<div class="row" '. $divAddi .'>
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-sm-2 control-label">'. $theme .'</label>
						<div class="col-sm-10">'. $value .'</div>
					</div>
				</div>
			</div>
			';
	}

	// 表单 内容
	public static function FormText2($theme, $value, $divAddi=''){
		return '
			<div class="row" '. $divAddi .'>
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-sm-2 control-label">'. $theme .'</label>
						<div class="col-sm-10" style="padding-top:6px;">'. $value .'</div>
					</div>
				</div>
			</div>
			';
	}

	// 表单 input 单文本
	public static function FormInput($id, $theme, $value, $addi='', $divAddi='', $inputAddi=''){
		return self::FormText(
			$theme, 
			'<input type="text" id="'. $id .'" name="'. $id .'" size="50" value="'. $value .'" class="form-control" '. $inputAddi .' />'. $addi, 
			$divAddi
			);
	}

	// 表单 textarea 多文本
	public static function FormTextarea($id, $theme, $value='', $addi='', $divAddi='', $height='95'){
		return self::FormText(
			$theme, 
			'<textarea id="'. $id .'" name="'. $id .'" cols="40" rows="4" style="height:'. $height .'px;" class="form-control">'. $value .'</textarea>'. $addi, 
			$divAddi
			);
	}

	// 表单 排序rank 单文本
	public static function FormRank($id, $theme, $value, $addi='<span style="color:red;">(值越小排越前)</span>', $divAddi='', $inputAddi=' style="width:80px;display:inline;"'){
		return self::FormText(
			$theme, 
			'<input type="text" id="'. $id .'" name="'. $id .'" size="50" value="'. $value .'" class="form-control" '. $inputAddi .' />'. $addi, 
			$divAddi
			);
	}

	// 表单 状态state 单选
	public static function FormState($id, $theme, $value, $addi='', $divAddi='', $textName=''){
		if ($textName == '启用'){
			$state1Name = '启用';
			$state2Name = '禁用';
		}else{
			$state1Name = '显示';
			$state2Name = '隐藏';
		}
		return self::FormText(
			$theme, 
			'<div class="itemR">
			<label class="normal"><input type="radio" name="'. $id .'" value="1" '. Is::Checked($value,1) .'>'. $state1Name .'</label>&ensp;&ensp;
			<label class="normal"><input type="radio" name="'. $id .'" value="0" '. Is::Checked($value,0) .'>'. $state2Name .'</label>&ensp;&ensp;
			</div>
			'. $addi, 
			$divAddi
			);
	}

	// 表单 日期时间datetime 单文本
	public static function FormDatetime($id, $theme, $value, $addi='', $divAddi='', $inputAddi=''){
		return self::FormText(
			$theme, 
			'<input type="text" id="'. $id .'" name="'. $id .'" size="50" value="'. $value .'" class="form-control Wdate" '. $inputAddi .' onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd HH:mm:ss"})\' />'. $addi, 
			$divAddi
			);
	}

	// 表单 日期date 单文本
	public static function FormDate($id, $theme, $value, $addi='', $divAddi='', $inputAddi=''){
		return self::FormText(
			$theme, 
			'<input type="text" id="'. $id .'" name="'. $id .'" size="50" value="'. $value .'" class="form-control Wdate" '. $inputAddi .' onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd"})\' />'. $addi, 
			$divAddi
			);
	}


	// 表单 submit按钮
	public static function FormSubmitBtn($btnName, $addi=''){
		return '
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label"></label>
						<div class="col-xs-10">
							<input type="submit" value=" '. $btnName .' " class="btn btn-info m-r-5" />
							'. $addi .'
							<span id="loadingStr"></span>
						</div>
					</div>
				</div>
			</div>
			';
	}


	// 显示箭头
	// menuName:菜单名称；str:显示箭头的值，str2:与str值对比；sort:上/下箭头；
	public static function ShowArrow($menuName,$str,$str2,$sort){
		$arrowStr = '';
		$URL = OT::GetParam(array('orderName','orderSort'), array('orderName'=>$str));
		if ($str==$str2){
			if ($sort=='ASC'){
				$URL .= '&amp;orderSort=DESC';
				$arrowStr = '<small>▲</small>';
			}else{
				$URL .= '&amp;orderSort=ASC';
				$arrowStr = '<small>▼</small>';
			}
		}else{
			$URL .= '&amp;orderSort=ASC';
		}
		return '<a href="'. $URL .'" style="color:#4d5259;">'. $menuName . $arrowStr .'</a>';
	}

	// 页头开通按钮
	public static function TopBtn($theme, $url, $style='', $limit=''){
		if (strlen($limit) > 0){
			global $vpsSysArr;
			if (empty($vpsSysArr)){ $vpsSysArr = Cache::PhpFile('vpsSys'); }
			if (strpos(''. $vpsSysArr['VS_funcStr'], $limit) === false){
				return '';
			}
		}
		return '
			<input type="button" value="'. $theme .'" class="btn subBtn2 btn-info" style="margin:0 12px 20px 0;'. $style .'" onclick="document.location.href=\''. $url .'\';" />
			';
	}


}
?>